<?php

namespace App\Http\Controllers\Api;

use App\Http\Requests\Api\ProductRequest;
use App\Models\Brand;
use App\Models\Product;
use App\Transformers\ProductTransformer;
use Carbon\Carbon;
use Chumper\Zipper\Facades\Zipper;
use Illuminate\Http\File;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;

class ProductsController extends Controller
{
    public function index(ProductRequest $request, Product $product)
    {
        $brandId = $request->brand_id;

        $products = $product->query()->where('brand_id', $brandId)
            ->orderBy('sort', 'desc')
            ->paginate(30, ['id', 'name', 'image', 'brand_id']);

        return $this->response->paginator($products, new ProductTransformer());
    }
}
